<template>
  <div class="container page">

    <div class="back">
        <ul>&nbsp;</ul>
        <ul class="txx"><img :src="userinfo.avatarUrl" class="tx"></ul>
        <ul class="nk">{{userinfo.nickName}}</ul>
    </div>

    <div v-if="!isLogin" style="text-align:center;margin-top:150rpx;display:flex">
        <p style="flex:1;color:#000;margin:0 80rpx;height: 60rpx;line-height: 60rpx;" @click="login">
          <img style="width:30%" src="http://www.hatchdo.com/wxmini/usercenter/login.png"  mode="widthFix" alt="">
        </p>
        <!-- <p style="flex:1"></p> -->
        <p style="flex:1;color:#fff;margin:0 80rpx;height: 60rpx;line-height: 60rpx;" @click="signup" >
          <img style="width:30%" src="http://www.hatchdo.com/wxmini/usercenter/signup.png"  mode="widthFix" alt="">
        </p>
    </div>

    <div v-if="!isLogin" style="text-align:center;margin-top:20rpx;display:flex">
        <p style="flex:1;margin:0 80rpx;height: 60rpx;line-height: 60rpx;" @click="login">登录</p>
        <!-- <p style="flex:1"></p> -->
        <p style="flex:1;margin:0 80rpx;height: 60rpx;line-height: 60rpx;" @click="signup" >注册</p>
    </div>

    <!-- <p v-if="isLogin" style="text-align:center;margin-top:100rpx;">用户xxxx</p> -->

    <div v-if="isLogin" class="one" @click="orderList">
        <ul class="zt"><p>我的订单</p></ul>
        <ul class="jr"><p>></p></ul>
    </div>

   <div v-if="isLogin" class="one" @click="shipping">
        <ul class="zt"><p>管理收货地址</p></ul>
        <ul class="jr"><p>></p></ul>
    </div>

    <div v-if="isLogin" class="one" @click="auth">
        <ul class="zt"><p>授权地址</p></ul>
        <ul class="jr"><p>></p></ul>
    </div>


    <div v-if="isLogin" class="one">
      <ul class="zt"><p>售后电话</p></ul>
      <ul class="jr"><p><b>400 820 2000</b></p></ul>
    </div>

   <!-- <div v-if="partnerlogin" class="one" @click="qrcode">
        <ul class="zt"><p>我的推广小程序码</p></ul>
        <ul class="jr"><p>></p></ul>
    </div> -->

   <div v-if="!partnerlogin&&!communitylogin&&isLogin" class="one" @click="goPartnerapply">
      <ul class="zt"><p>申请成为合伙人</p></ul>
      <ul class="jr"><p>></p></ul>
   </div>

   <div v-if="partnerlogin" class="one" @click="goPartner">
      <ul class="zt"><p>合伙人</p></ul>
      <ul class="jr"><p>></p></ul>
   </div>

   <!-- <div v-if="communitylogin" class="one" @click="goPartner">
      <ul class="zt"><p>社区合伙人</p></ul>
      <ul class="jr"><p>></p></ul>
   </div> -->

            <!-- <div class="bk">退出登录</div> -->


    <!-- <div v-if="isLogin" style="text-align:center;margin-top:100rpx;">
            <div style="text-align:center;margin-top:100rpx;display:flex">
                <p style="flex:1;color:#44CFDC;" @click="orderList">我的订单</p>
            </div>
    </div> -->


    
        <p v-if="isLogin" style="text-align:center;margin:250rpx; background-color: #000;color: #fff;height:60rpx;line-height:60rpx;" @click="loginout">退出登录</p>
      <img src="https://www.hatchdo.com/wxmini/usercenter/bottom.png" style="width:100%" mode="widthFix">


  </div>
</template>
<script>
// var WXBizDataCrypt = require('@/tools/WXBizDataCrypt')
import {showSuccess, showModal} from '@/util'
import {get, post} from '@/util'
// import {get2, post2} from '@/server/api'
import config from '@/config'
export default {
  components: {
  },
  data () {
    return {
      userinfo: {},
      isLogin: false,
      communitylogin: false,
      partnerlogin: false,
      tabA: 0,
      productList: [],
      focus: true,
      inputValue: ''
    }
  },
  mounted () {
    // this.userinfo = wx.getStorageSync('userinfo')
  },
  onShareAppMessage() {
    return {
      title: `为女性恢复年轻及孩子健康成长提供一站式解决方案。`,
      // imageUrl: 'https://www.rrjiaoyi.com/static/rr-min/share/share.png',
      path: `/pages/hcdindex/main?shareuser=${wx.getStorageSync('user').id}`
    }
  },
  methods: {
    auth() {
      wx.openSetting()
    },
    async shipping() {
        wx.chooseAddress({

          success: res => {
            this.address = res
            // console.log(this.address)
            // console.log(JSON.stringify(this.address))

          }

        })

    },
    goPartnerapply(){
      wx.navigateTo({
        url: `/pages/partnerapply/main`
      }) 
    },
    goPartner() {
      wx.navigateTo({
        url: `/pages/partner/main`
      }) 
    },
    qrcode() {
      wx.navigateTo({
        url: `/pages/qrcode/main`
      }) 
    },
    // 社区合伙人是否登录
    isCommunitylogin() {
      post(`geweb/user/checkcommunity`, {}, {"token":wx.getStorageSync('token'),"userId":wx.getStorageSync('user').id})
      .then(result => {
      if(result.result === 'success') {
      // console.log(this.isLogin)   

      this.communitylogin = true
      // console.log(this.isLogin)   

      }

      if(result.code === 301) {
        this.communitylogin = false
      }


      })
    },
    // 合伙人是否登录
    isPartnerlogin(){
      post(`geweb/user/checkpartner`, {}, {"token":wx.getStorageSync('token'),"userId":wx.getStorageSync('user').id})
      .then(result => {
      if(result.result === 'success') {
      // console.log(this.isLogin)   

      this.partnerlogin = true
      // console.log(this.isLogin)   

      }

      if(result.code === 301) {
        this.partnerlogin = false
      }


      })
    },
    // 普通用户是否登录
    lslogin(){
      post(`geweb/user/checkuser`, {}, {"token":wx.getStorageSync('token'),"userId":wx.getStorageSync('user').id})
      .then(result => {
      if(result.result === 'success') {
      // console.log(this.isLogin)   

      this.isLogin = true
      // console.log(this.isLogin)   

      }

      if(result.code === 301) {
        this.isLogin = false
      }


      })
    },
    loginout() {
      wx.setStorageSync('scene', "")
      wx.setStorageSync('token', "")
      wx.setStorageSync('userinfo', "")
      wx.setStorageSync('user', "")
      wx.setStorageSync('session_key', "")
      this.isLogin = false
      this.partnerlogin = false
      this.communitylogin = false
          wx.showToast({
            title: '退出登录',
            icon: 'none'
          })

      wx.switchTab({
        url: `/pages/hcdindex/main`
      })

    },
    login(){
      wx.navigateTo({
        url: `/pages/me/main`
      })
    },
    signup(){
      wx.navigateTo({
        url: `/pages/signup/main`
      })
    },
    orderList() {
      wx.navigateTo({
        url: `/pages/orderlist/main`
      })
    },
    productChoose (id) {
      // console.log(name, img, userId, accountId)
      wx.navigateTo({
        url: `/pages/product-detail/main?id=${id}`
      })
    },
    async player() {
      return await post('minipro/List', {}, {'api':'all', 'page':1})
    },
    async demo() {
    // return await get2('demo', {})
    },
    async joke() {
      return await get2('api/jokes', {})
    },
    predict () {
      wx.navigateTo({
        url: '/pages/search/main'
      })
    },
    jumpClick (comment) {
      wx.navigateTo({
        // url: '/pages/web-view/main'
        url: '/pages/web-view/main?path=' + 'https://wj.qq.com/s/2491547/f457/'
        // url: '/pages/detail/main'
      })
    }

  },
  onShow () {
    // Object.assign(this.$data, this.$options.data())
    // setTimeout(() => {
    this.lslogin()
    this.isPartnerlogin()
    // this.isCommunitylogin()
    if(wx.getStorageSync('userinfo')) {
     this.userinfo = JSON.parse(wx.getStorageSync('userinfo').rawData)
    }

      // console.log(wx.getStorageSync('userinfo').rawData)
    // }, 100)

    


    
    // this.get_product("")
  }
}
</script>

<style scoped lang='scss'>
.container{
  font-size: 30rpx;
}
page {
  background-color: #ffffff;
  width: 100%;
  height: 100%;
}
.section {
  text-align: center;
  margin-top: 200rpx;
  padding: 0 100rpx;
  display: flex;
  height: 80rpx;
  line-height: 80rpx;
}
.recomond {
  margin: 0 25rpx;
  margin-top: 25rpx;  
  height: 100rpx;
  line-height: 100rpx;
  text-align: center;
  display: flex;
  p {
    flex: 1;
  }
}
.choose {
  color: #44CFDC;
}

.productList {
  margin: 0 25rpx;
  margin-top: 50rpx;
  border: 1px solid #ddd;
  border-radius: 4px;
  height: 200rpx;
  // line-height: 200rpx;
  display: flex;
  text-align: center;
  div {
    flex: 1;
      img{
        width: 180rpx;
        height:180rpx;
        margin: 10rpx;
        // border-radius: 50%;
    }
  }
  .des{
    width: 400rpx;
    flex: 3;
    height: 200rpx;
    margin: 10rpx 30rpx;
    p {
      text-align: left;
      line-height: 60rpx;
    }
    .price {
      display: flex;
      span {
        flex: 1;
      }
    }
  }
}

.foot {
  color: rgb(45, 161, 187);
  text-align: center;
  margin-top: 200rpx;
}
.one{
    display: flex;
}
.back{
  margin-top: 100rpx;
    // background-image:url(https://www.hatchdo.com/wxmini/Personal/bg.png);
    // width: 100%;
    // height: 300rpx;
}
.tp{
    width: 100%;
    height: 350rpx;
}
.txx{
    text-align: center;
}
.nk{
    text-align: center;
    margin-bottom: 1rem;
}
.ull{
    text-align: center;
    flex: 1;
}
.tp{
    width: 100%;
}
.tx{
    width: 60px;
    height: 60px;
    text-align: center;
    /* margin-top: 1rem;  */
    border-radius: 30px;
    
}
.dh{
    flex: 1;
    text-align: center;
	
}
.zt{
    flex: 1;
    // background: #C8D3D1;
    background-color: #e6e6e6;
    margin-top: 50rpx;
    text-align: left;
	height:80rpx;
    line-height: 80rpx;
	    padding: 0 50rpx;
}
.jr{
    flex: 1;
    // background: #C8D3D1;
    background-color: #e6e6e6;
    margin-top: 50rpx;
    text-align: right;
	height:80rpx;
    line-height: 80rpx;
	    padding: 0 50rpx;
}
.tt{
display: table-cell;
    vertical-align:middle;
}
.button{
    text-align: center;
    margin-top: 6rem;

}
.yzm{
	border-radius:4px;
	height:25px;
}
.bk{
	height:30px;
	width:80px;
	font-weight:bold;
}
</style>
